package com.abel.bigwater.wflow

import org.activiti.api.task.runtime.TaskRuntime
import org.activiti.engine.delegate.DelegateTask
import org.activiti.engine.delegate.TaskListener
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
class LossAssignTaskListener : TaskListener {
    @Autowired
    var taskRuntime: TaskRuntime? = null

    override fun notify(delegateTask: DelegateTask?) {
        lgr.info("td id: ${delegateTask?.id}, assignee: ${delegateTask?.assignee}, instance: ${delegateTask?.processInstanceId}")

        val task = taskRuntime?.task(delegateTask?.id)
        lgr.info("task-id: ${task?.id}, ${task?.name}")
    }


    companion object {
        private val lgr = LoggerFactory.getLogger(LossAssignTaskListener::class.java)
    }
}